package cn.getech.data.metadata.model.req.setting;

import cn.getech.data.metadata.api.gateway.model.dto.CollectionSetting;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
public class CollectionSettingReq {

    /**
     * 主键
     */
    private Integer id;
    private Integer currentTreeLevelMax;
    private Integer currentCategoryLevelMax;
    /**
     * 所属树目录层级
     */
    private Integer treeLevelMax;

    /**
     * 资产目录层级
     */
    private Integer categoryLevelMax;

    /**
     * 1 数据资产管理平台 2 对接外部平台
     */
    private Integer approvalPlatform;

    /**
     * 1根据设置的审批人顺序进行审批
     */
    private Integer approvalProcess;

    /**
     * 1 资产类目的目录负责人
     */
    private Integer approvalDataSource;

    /**
     * 权限设置
     */
    private List<DataLevelSettingReq> DataLevelSettingList;
    public CollectionSettingReq(){
        this.id = 1;
        this.treeLevelMax = 2;
        this.categoryLevelMax = 2;
        this.approvalPlatform = 1;
        this.approvalProcess = 1;
        this.approvalDataSource = 1;
    }
    public CollectionSettingReq(CollectionSetting config) {
        this.id = config.getId();
        this.treeLevelMax = config.getTreeLevelMax();
        this.categoryLevelMax = config.getCategoryLevelMax();
        this.approvalPlatform = config.getApprovalPlatform();
        this.approvalProcess = config.getApprovalProcess();
        this.approvalDataSource = config.getApprovalDataSource();
    }

    public CollectionSetting toDto() {
        CollectionSetting setting=new CollectionSetting();
        setting.setId(this.id);
        setting.setTreeLevelMax(this.treeLevelMax);
        setting.setCategoryLevelMax(this.categoryLevelMax);
        setting.setApprovalPlatform(this.approvalPlatform);
        setting.setApprovalProcess(this.approvalProcess);
        setting.setApprovalDataSource(this.approvalDataSource);
        setting.setUpdateTime(new Date());
        return setting;
    }
}
